package net.lab1024.sa.admin.module.business.erp.bas.controller;

import net.lab1024.sa.admin.module.business.erp.bas.domain.form.BatchordAddForm;
import net.lab1024.sa.admin.module.business.erp.bas.domain.form.BatchordQueryForm;
import net.lab1024.sa.admin.module.business.erp.bas.domain.form.BatchordUpdateForm;
import net.lab1024.sa.admin.module.business.erp.bas.domain.vo.BatchordVO;
import net.lab1024.sa.admin.module.business.erp.bas.service.BatchordService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 请购单 Controller
 *
 * @Author AKITA
 * @Date 2025-08-02 14:56:12
 * @Copyright AKITA
 */

@RestController
@Tag(name = "请购单")
public class BatchordController {

    @Resource
    private BatchordService batchordService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/batchord/queryPage")
    public ResponseDTO<PageResult<BatchordVO>> queryPage(@RequestBody @Valid BatchordQueryForm queryForm) {
        return ResponseDTO.ok(batchordService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/batchord/add")
    public ResponseDTO<String> add(@RequestBody @Valid BatchordAddForm addForm) {
        return batchordService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/batchord/update")
    public ResponseDTO<String> update(@RequestBody @Valid BatchordUpdateForm updateForm) {
        return batchordService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/batchord/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return batchordService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/batchord/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return batchordService.delete(id);
    }
}
